# @Time : 2020/7/27 15:57
# @Author : Fioman 
# @Phone : 13149920693
import cv2 as cv
import numpy as np

"""
礼帽运算是用原始图像减去其开运算图像的操作.
礼帽操作能够获取图像的噪声信息,或者得到比原始图像边缘更亮的边缘信息.
"""
img = cv.imread("test.bmp",cv.IMREAD_GRAYSCALE)
kernel = np.ones((5,5),dtype=np.uint8)
topHat = cv.morphologyEx(img,cv.MORPH_TOPHAT,kernel,iterations=10)

cv.imshow("Original",img)
cv.imshow("Tophat",topHat)

cv.waitKey(0)
cv.destroyAllWindows()